Linux System Service

Let’s create a file called /etc/systemd/system/rot13.service

[Unit]
Description=ROT13 demo service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=centos
ExecStart=/usr/bin/env php /path/to/server.php

[Install]
WantedBy=multi-user.target

set your actual username after User=
set the proper path to your script in ExecStart=
That’s it. We can now start the service:

systemctl start rot13

And automatically get it to start on boot:

systemctl enable rot13

Credits

index